var express = require('express'),
    router = express.Router(),
    studentService = require('../service/student.js');

// 该路由器使用的 时间日志 中间件
router.use(function (req, res, next) {
    console.log('Come in main router at time(ms): ', Date.now());
    next();
});

// 定义网站主页的路由
router.get('/', function (req, res) {
    studentService.getStudents(function (students) {
        res.render('index', {
            welcomeText: 'Hello World.',
            students: students
        });
    });
});
// 定义 about us 页面的路由
router.get('/about-us', function (req, res) {
    res.render('about-us');
});

module.exports = router;